package com.xu.demo.proxyPattern;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

// 动态代理处理器
public class ShoppingInvocationHandler implements InvocationHandler {

    private Object target;

    public ShoppingInvocationHandler(Object target) {
        this.target = target;
    }

    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        System.out.println("开始记录日志");
        Object result = method.invoke(target, args);
        System.out.println("记录日志完成");
        return result;
    }
}

